<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="Access-Control-Allow-Origin" content="*">
<meta name="viewport"
	content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta http-equiv="Cache-Control" content="no-siteapp" />
<title>首页</title>
<link rel="stylesheet" href="/Goktech-Bank-System/common/layui/css/layui.css">
<link rel="stylesheet" href="/Goktech-Bank-System/common/css/sccl.css">
<link rel="stylesheet"
	href="/Goktech-Bank-System/common/iconfont/1.0.1/iconfont.css" />
<link rel="shortcut icon" href="favicon.ico" />
</head>

<body class="login-bg">
	<div class="login-box">
		<header>
			<h1>后台管理系统</h1>
		</header>
		<div class="login-main">
			<form action="" id="loinfom" enctype="multipart/form-data"
				class="layui-form" method="post">
				<input name="__RequestVerificationToken" type="hidden" value="">
				<div class="layui-form-item">
					<label class="login-icon"> <i class="layui-icon iconfont">&#xe612;</i>
					</label> <input type="text" name="userName" lay-verify="userName"
						autocomplete="off" placeholder="这里输入登录名" class="layui-input">
				</div>
				<div class="layui-form-item">
					<label class="login-icon"> <i class="layui-icon iconfont">&#xe642;</i>
					</label> <input type="password" name="password" lay-verify="password"
						autocomplete="off" placeholder="这里输入密码" class="layui-input">
				</div>
				<div class="layui-form-item">
					<label class="login-icon"> <i class="layui-icon iconfont">&#xe642;</i>
					</label> <input style="display: inline; width: 170px" type="password"
						name="password" lay-verify="code" autocomplete="off"
						placeholder="这里输入验证码" class="layui-input"> <input
						id="btnSendCode"
						style="margin: 0px; padding: 0px 10px; border-radius: 4px; height: 38px; background-color: #ec6817; border: 0px; cursor: pointer; color: #000000"
						onclick="getCode()" value="获取验证码" type="button">
				</div>
				<div class="layui-form-item">
					<div class="pull-left login-remember">
						<label>记住帐号？</label> <input type="checkbox"
							lay-filter="rememberMe" name="rememberMe" value="true"
							lay-skin="switch" title="记住帐号">
						<div class="layui-unselect layui-form-switch">
							<i></i>
						</div>
					</div>
					<div class="pull-right">
						<button class="layui-btn layui-btn-primary" lay-submit=""
							lay-filter="login">
							登录<i class="layui-icon iconfont">&#xe602;</i>
						</button>
					</div>
					<div class="clear"></div>
				</div>
			</form>
		</div>
		<footer>
			<p>XXX系统</p>
		</footer>
	</div>
	<!-- <img src="/Goktech-Bank-System/common/layui/images/face/0.gif" /> -->
	<script type="text/html" id="code-temp">
        <div class="login-code-box">
            <input type="text" class="layui-input" id="code" />
            <img id="valiCode" src="http://192.168.1.115:8080/health/image.jsp" alt="验证码" />
        </div>
    </script>
	<script type="text/javascript"
		src="/Goktech-Bank-System/common/lib/jquery-1.9.0.min.js"></script>
	<script type="text/javascript"
		src="/Goktech-Bank-System/common/js/jquery.xdomainrequest.min.js"></script>
	<script src="/Goktech-Bank-System/common/layui/layui.js"></script>
	<script src="/Goktech-Bank-System/common/js/md5.js"></script>
	<script src="/Goktech-Bank-System/common/js/sccl-util.js"></script>

	<script>
		$(function() {
			jQuery.support.cors = true;
			layui.use(
							[ 'layer', 'form' ],
							function() {
								var layer = layui.layer, $ = layui.jquery, form = layui
										.form();

								form.verify({
									userName : function(value) {
										if (value === '')
											return '请输入用户名';
									},
									password : function(value) {
										if (value === '')
											return '请输入密码';
									}
								});

								var errorCount = 4;
								form.on('switch(rememberMe)', function(data) {
									console.log(data.elem.checked); //是否被选中，true或者false
									if (data.elem.checked == true) {
										console.log("已选中");
									} else {
										console.log("没选中");
									}
									;
								})
								form
										.on(
												'submit(login)',
												function(data) {
													//window.location.href = "index.html";
													if (errorCount > 5) {
														layer
																.open({
																	title : '<img src="/Goktech-Bank-System/common/layui/images/face/0.gif" alt="[害羞]">输入验证码',
																	type : 1,
																	content : document
																			.getElementById('code-temp').innerHTML,
																	btn : [ '确定' ],
																	yes : function(
																			index,
																			layero) {
																		var $code = $('#code');
																		if ($code
																				.val() === '') {
																			layer
																					.msg('输入验证码啦，让我知道你是人类。');
																			isCheck = false;
																		} else {
																			var params = {};
																			params.checkNum = $(
																					"#code")
																					.val();
																			params.username = $(
																					'input[name=userName]')
																					.val();
																			params.password = hex_md5($(
																					'input[name=password]')
																					.val());
																			//  params=JSON.stringify(params);
																			console
																					.log(params)
																			submit(
																					$,
																					params);
																			layer
																					.close(index);
																		}
																	},
																	area : [
																			'250px',
																			'150px' ]
																});
														$('#valiCode')
																.off('click')
																.on(
																		'click',
																		function() {
																			this.src = myurl()
																					+ '/health/image.jsp?v='
																					+ new Date()
																							.getTime();
																		});
													} else {
														var params = {};
														params.username = $(
																'input[name=userName]')
																.val();
														/* params.password = hex_md5($(
																'input[name=password]')
																.val()); */
														params.password =$(
														'input[name=password]')
														.val();
														//params=JSON.stringify(params);
														submit($, params);
													}

													return false;
												});

							});

			function submit($, params) {
				//!!!!!!!!!这里是提交逻辑
				console.log(params);
				//通过ajax发送请求到服务器
				$.get("/Goktech-Bank-System/yongh/login",params,function(data){
					console.log(data)
					if(data.code==1)
						{
						location.href='/Goktech-Bank-System/page/index.html';
						
						}else{
							alert(data.message)
						}
				}
				);
			//	window.location.href = "page/index.html";
				//登录逻辑
				//var url=myurl()+"/admin/innerUser/login"+"?"+new Date().getTime();
				/*ajax(url,params,"json",function(data){
					console.log(data);
					if(data.code==1){
						window.location.href="index.html";
					}else{
						layer.msg('登录失败');
					}
				})*/
				//	ajax(url,params,"json","")
				// $("#loinfom").attr("action",url);
				//    $("#loinfom").submit();
			}

		})
		var InterValObj; //timer变量，控制时间
		var count = 120; //间隔函数，1秒执行
		var curCount; //当前剩余秒数

		function getCode() {　
			//验证手机号对不对 
						curCount = count;　　 //设置button效果，开始计时
						$("#btnSendCode").attr("disabled", "true");
						$("#btnSendCode").css("background-color", "#eee")
						$("#btnSendCode").val("" + curCount + "秒后再尝试");
						$("#phone").attr("readonly", "true");
						InterValObj = window.setInterval(SetRemainTime, 1000); //启动计时器，1秒执行一次
		}

		//timer处理函数
		function SetRemainTime() {
			if(curCount == 0) {
				window.clearInterval(InterValObj); //停止计时器
				$("#btnSendCode").removeAttr("disabled"); //启用按钮
				$("#btnSendCode").val("重新发送验证码");
				$("#phone").removeAttr("readonly"); //启用手机号输入框
				$("#btnSendCode").css("background-color", "#ec6817")
			} else {
				curCount--;
				$("#btnSendCode").val("" + curCount + "秒后再尝试");
			}
		}
	</script>
</body>
</html>
